package com.work.cos.util;

import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.work.cos.domain.vo.ComServiceResVo;

public class ThirdPullUtil {
	
	private static Logger LOGGER = LoggerFactory.getLogger(ThirdPullUtil.class);
	
	private static String appKey = "d912e9a8084bb2472e03ca65";
	private static String masterSecret = "0a7137c43792ab74d219c4c8";
	
	/**
	 * 极光注册
	 * @param userId
	 * @param password
	 * @return
	 */
	public static ComServiceResVo sendRegisterInfo(String userId, String password) {		
		try {
			
			JSONObject obj = new JSONObject();
			obj.put("username", "anbixin" + userId);
			obj.put("password", password);
			
			JSONArray arrayObj = new JSONArray();
			arrayObj.put(obj);
			
			String[] strArray = HttpClientUtil.doPostBasic("https://api.im.jpush.cn/v1/users/",
					appKey + ":" + masterSecret , arrayObj.toString());
			
			return ComServiceResVo.returnEntity(strArray);
		} catch (Exception e) {
			
			LOGGER.error("极光注册失败... msg={}", e.getMessage());
			return ComServiceResVo.returnErrorMessage(""); 
		}
	}
	
	
	/*public static void main(String[] args) {
		
		System.out.println(sendRegisterInfo("1", "123456"));
	}*/

}
